package com.example.careycai.notepad;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.WindowManager;
import android.widget.EditText;

/**
 * Created by shelly.xu on 12/28/2015.
 */
public class TelEdit extends EditText {
    Context mcontext;
    public TelEdit(Context context) {
        super(context);
        mcontext=context;
    }

    public TelEdit(Context context, AttributeSet attrs) {
        super(context, attrs);
        mcontext=context;
    }

    public TelEdit(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mcontext=context;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        WindowManager wm=(WindowManager)mcontext.getSystemService("window");
        int windowWidth=wm.getDefaultDisplay().getWidth();
        int windowHeight=wm.getDefaultDisplay().getHeight();

        Paint paint=new Paint();
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.BLACK);

        int paddingTop=getPaddingTop();
        int paddingBottom=getPaddingBottom();

        int scrollY=getScrollY();
        int scrollX=getScrollX()+windowWidth;
        int innerHeight=scrollY+getHeight()-paddingTop-paddingBottom;
        int lineHeight=getLineHeight();
        int baseLine=scrollY+(lineHeight-(scrollY%lineHeight));

        int x=8;
        while(baseLine<innerHeight){
            canvas.drawLine(x,baseLine+paddingTop,scrollX,baseLine+paddingTop,paint);
            baseLine+=lineHeight;
        }
        super.onDraw(canvas);
    }
}
